package com.lyz.dataStructure.JianZhiOffer;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 19:14
 * @Description:
 **/

import com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport;
/*
大家都知道斐波那契数列，现在要求输入一个整数n，请你输出斐波那契数列的第n项（从0开始，第0项为0）。
n<=39
 */
import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/6/18 19:14
 *@Description:
 **/
public class Test8 {
    public static int Fibonacci(int n) {
        int a=1,b=1,c=0;
        if(n<0){
            return 0;
        }else if(n==1||n==2){
            return 1;
        }else{
            for (int i=3;i<=n;i++){
                c=a+b;
                b=a;
                a=c;
            }
            return c;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
           int n = sc.nextInt();
            System.out.println(Fibonacci(n));
        }
    }
}
